using System;
using System.Collections.Generic;

namespace Dimebrain.TweetSharp.Core.Caching
{
    /// <summary>
    /// A simple caching interface that supports absolute and sliding expiration.
    /// </summary>
    public interface IClientCache
    {
        ///<summary>
        /// The number of stored key value pairs currently in the cache.
        ///</summary>
        int Count { get; }

        /// <summary>
        /// All of the keys currently in the cache.
        /// </summary>
        IEnumerable<string> Keys { get; }
        
        /// <summary>
        /// Caches a new value under the specified key. 
        /// </summary>
        /// <param name="key">The key</param>
        /// <param name="value">The value</param>
        void Insert(string key, object value);
        
        /// <summary>
        /// Caches a new value under the specified key, with an absolute expiration.
        /// </summary>
        /// <param name="key">The key</param>
        /// <param name="value">The value</param>
        /// <param name="absoluteExpiration">The absolute expiration of the cached value</param>
        void Insert(string key, object value, DateTime absoluteExpiration);

        /// <summary>
        /// Caches a new value under the specified key, with an absolute expiration.
        /// </summary>
        /// <param name="key">The key</param>
        /// <param name="value">The value</param>
        /// <param name="slidingExpiration">The sliding inactivity expiration of the cached value</param>
        void Insert(string key, object value, TimeSpan slidingExpiration);
        
        /// <summary>
        /// Retrieves a value from the cache, strongly typed to the value's type.
        /// </summary>
        /// <typeparam name="T">The expected type of the cached value</typeparam>
        /// <param name="key">The key</param>
        /// <returns></returns>
        T Get<T>(string key);
        
        /// <summary>
        /// Removes a value from the cache by its key.
        /// </summary>
        /// <param name="key">The key</param>
        void Remove(string key);
    }
}